package com.sc.nft.controller;




import com.sc.nft.annotation.UserLogin;
import com.sc.nft.entity.vo.SearchListVO;
import com.sc.nft.entity.vo.salvageEvents.SalvageEventsPageVO;
import com.sc.nft.pool.UserPool;
import com.sc.nft.service.SearchService;
import com.sc.nft.sup.PageRequest;
import com.sc.nft.sup.PageResult;
import com.sc.nft.sup.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * 搜索配置(Search)表控制层
 *
 * @author 王伟成
 * @since 2024-03-05 15:16:44
 */

@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/search")
@Api(tags = "搜索")
public class SearchController {
    /**
     * 服务对象
     */
    private final SearchService searchService;


    @ApiOperation(value = "搜索集合列表", notes = "搜索集合列表", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/displayList", produces = MediaType.APPLICATION_JSON_VALUE)
    @UserLogin
    public Result<List<SearchListVO>> displayList()  {
        List<SearchListVO> searchListVOS = searchService.displayListForUser(UserPool.getUser().getId());
        for (SearchListVO searchListVO : searchListVOS) {
            searchListVO.setIsConsensus(searchListVO.getId().longValue()==9L);
        }
        return Result.success(searchListVOS);
    }

   
}
